//
//  WFCaseViewController.m
//  谷居
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFCaseViewController.h"
#import "WFCaseTableView.h"
#import "WFCaseCell.h"
#import "AFNetworking.h"
#import "WFFailView.h"
#import "WFHandleURL.h"
#import "NetWorkingTool.h"

#import "WFProjectModel.h"
#import "WFUserModel.h"
#import "WFUserimageModel.h"
#import "WFUserimageModel.h"
#import "WFCarouselModel.h"

#import "YJPCycleView.h"

#import "WFNavigationView.h"

#import "WFSaveTool.h"


#import "WFInformationVC.h"
#import "StoreSandBox.h"
#import "MJRefresh.h"

#import "WFGuideTitleModel.h"


#import "MBProgressHUD.h"
#import "WFSearchViewController.h"
@interface WFCaseViewController ()
<
UITableViewDelegate,
UITableViewDataSource,
WFFailViewDelegate,
YJPCycleViewDelegate,
WFCaseCellDelegate ,/** 刷熊tableView的协议. */
WFNavigationViewDelegate
>

//@property (nonatomic, retain)WFCarouselScrollView *carouseScrollView;
//@property (nonatomic, retain)NSMutableArray *carouselArray;

@property (nonatomic, retain)WFCaseTableView *caseTableView;

@property (nonatomic, retain)UIImageView *navBarHairlineImageView; /** 存储navigation的. 设置下划线隐藏. */

@property (nonatomic, retain) UIButton *photoButton; /** 头像. */

@property (nonatomic, retain) UIImageView *titleImageView; /** 标题图片. */

@property (nonatomic, retain) UIButton *searchButton; /** 搜索按钮. */

@property (nonatomic, retain) WFFailView *failView; /** 网络请求失败的view. */

@property (nonatomic, retain) NSMutableArray *projectArray;

@property (nonatomic, retain) NSMutableArray *userArray;

@property (nonatomic, retain) NSMutableArray *userImageArray;

@property (nonatomic, retain) NSMutableArray *carouselArray;

@property (nonatomic, retain) WFNavigationView *navigationView;

@property (nonatomic, retain) YJPCycleView *carouselView;

@property (nonatomic, retain) NSMutableDictionary  *titleDic;

@property (nonatomic, retain) NSMutableDictionary *picsTitleDic; /** 图库标题的字典. */

@property (nonatomic, retain) NSMutableDictionary *guideTitleDic; /** 攻略标题字典. */

@property (nonatomic, assign) NSInteger start; /** 上拉刷新的次数. */

@property (nonatomic, assign) NSInteger count;

/** 关于本地缓存. */
@property (nonatomic, assign) BOOL isNeedToRequest; /** 是否需要网络请求. */

@property (nonatomic, assign) BOOL isHadData; /** 判断是否有本地数据. */

@property (nonatomic, retain) NSMutableArray *photoImageArray; /** 存储image图片的数组. */

@property (nonatomic, retain) NSMutableArray *imageArray; /** 存储头像图片的数组. */

@property (nonatomic, retain) NSMutableArray *carouseCachesArray; /** 轮播图的缓存的数组. */
@property (nonatomic, assign) BOOL cellImageStyle;


@property (nonatomic, assign) NSInteger style;
@property (nonatomic, assign) NSInteger area;
@property (nonatomic, assign) NSInteger cost;
@property (nonatomic, assign) NSInteger type;
@end

@implementation WFCaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
 
    
#pragma mark - 在进入界面是加载数据
    
    /** 判断是否有本地缓存以及缓存是否过期. */
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isSave"]) {
        
        /** 如果有本地数据的话, 先直接做本地请求. */
        [self makeRequestWithCaches];
        self.cellImageStyle = 0;
        /** 获取当前时间/. */
        NSString *locationTime = [self getLastTime];
        
        /** 获取上次刷新时间. */
        NSString *lastTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"time"];
        /** 对比当前时间和上次刷新时间. 如果差小于5, 不刷新数据.*/
        NSInteger lastTimeInt = [lastTime integerValue];
        NSInteger locationInt = [locationTime integerValue];
        
        if (labs(lastTimeInt - locationInt) >= 5) {
            NSLog(@"网络刷新数据. ");
            self.cellImageStyle = 1;
            [self refresh];
        } else {
            NSLog(@"本地请求数据. ");
        }

    } else {
        /** 没有本地数据直接做网络请求. */
        self.cellImageStyle = 1;
        [self refresh];
        NSLog(@"网络请求数据. ");
    }
#pragma mark - 创建轮播图的方法.

    
    [self createCarouselVieData];
    
    
    /** 请求成功后创建tableView. 并且将之前的FailView移除. */
    [self createTableView];
    

    
    
    
    
    
#pragma mark - 创建导航栏下面的
    
    _navigationView = [[WFNavigationView alloc] initWithFrame:NA_FRAME];
    [self.view addSubview:_navigationView];
    [_navigationView release];
    _navigationView.buttonCount = 4;
    _navigationView.navigationType = 0;
    
    /** 签订协议. */
    _navigationView.delegate = self;
    /** 将下划线去除. */
    _navBarHairlineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];

#pragma mark - 关于导航栏的布局
   
    
    /** 创建标题图片. */
    [self createTitleView];
    
    /** 创建搜索按钮. */
    [self createSearchButton];
    
    
#pragma mark - 添加通知中心
//    [self addObserver];
    
    
    
#pragma mark - 判断程序是否是第一次启动
    if ([self isProjectFirstOpen]) {
        [self requsetForTitle];
    }
}


- (void)backTorefreshTableViewWithId:(NSString *)_id indexType:(NSInteger)type{
    switch (type) {
        case 0:
            self.area = _id.integerValue;
            break;
            case 1:
            self.cost = _id.integerValue;
            break;
            case 2:
            self.type = _id.integerValue;
            break;
            case 3:
            self.style = _id.integerValue;
            break;
            
        default:
            break;
    }
    
    NSLog(@"index: %ld", type);
    NSLog(@"id: %@", _id);
    NSLog(@"tableView被刷新");
    _caseTableView.contentOffset = CGPointMake(0, 0);
    [self refresh];
}

- (BOOL)isProjectFirstOpen {
    if (![[NSUserDefaults standardUserDefaults] objectForKey:@"firstOpen"]) {
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"firstOpen"];
        return YES;
    } else {
        return NO;
    }
    
}


- (void)requsetForTitle {
    if (![self isProjectFirstOpen]) {
        [self createPicsTitleDic];
        [self createGuideTitleDic];
    }
}

- (void)createPicsTitleDic {
    [NetWorkingTool netWorkingWithURL:@"http://api.guju.com.cn/v2/photo/map" block:^(id result) {
        [[NSUserDefaults standardUserDefaults] setObject:result forKey:@"picsTitleDic"];
    }];
}
- (void)createGuideTitleDic {
    [NetWorkingTool netWorkingWithURL:@"http://api.guju.com.cn/v2/strategy/banner" block:^(id result) {
        
        NSDictionary *guideDic = result[@"type"];
        [[NSUserDefaults standardUserDefaults] setObject:guideDic forKey:@"guideTitleDic"];
    }];
}


#warning lazyLoad
- (NSMutableDictionary *)picsTitleDic {
    if (_picsTitleDic == nil) {
        _picsTitleDic = [[NSMutableDictionary dictionary] retain];;
        
    }
    return _picsTitleDic;
}

- (NSMutableDictionary *)guideTitleDic {
    if (_guideTitleDic == nil) {
        _guideTitleDic = [[NSMutableDictionary dictionary] retain];
    }
    return _guideTitleDic;
}


#pragma mark - 进行本地请求
- (void)makeRequestWithCaches {
    self.projectArray = [[StoreSandBox shareStoreSandBox]readByArchiver:@"projectArray.plist"];
    self.imageArray = [[StoreSandBox shareStoreSandBox] readByArchiver:@"imageArray.plist"];
    self.photoImageArray = [[StoreSandBox shareStoreSandBox] readByArchiver:@"photoImageArray.plist"];
    self.carouseCachesArray = [[StoreSandBox shareStoreSandBox] readByArchiver:@"carouseCachesArray.plist"];
    
    self.userArray = [[StoreSandBox shareStoreSandBox] readByArchiver:@"userArray.plist"];
    NSLog(@"user: %@", self.userArray);
    
    
//    NSLog(@"image: %@", self.imageArray);
};

#pragma mark - 进行网络请求
/** 网络请求. yes的时候为普通刷新, 不添加数组.*/
- (void)makeRequestWithUrl:(NSString *)url upDown:(BOOL)upDown{
    /** 通过判断是否请求成功改变界面. */
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    [manager GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        /** 处理数据. */
        /** 当yes的时候, 将数组的元素都移除, 重新刷新. no的时候将请求的数据添加. */
        NSArray *projectArr = [responseObject valueForKey:@"projects"];
        NSMutableArray *array = [WFProjectModel baseModelByArray:projectArr];
        if (upDown) {
            [self.projectArray removeAllObjects];
            [self.projectArray addObjectsFromArray:array];
            [self createUserAndImageArray];
            
            /** 将第一次请求的一页数据存储到本地. */
            
            /** 清楚所有的内容. */
            [self.imageArray removeAllObjects];
            [self.photoImageArray removeAllObjects];
            
            [[StoreSandBox shareStoreSandBox] storeByArchiver:self.projectArray key:@"projectArray.plist"];
            NSLog(@"%@", self.userArray);
            [[StoreSandBox shareStoreSandBox] storeByArchiver:self.userArray key:@"userArray.plist"];
            /** 将图片缓存到本地. */
            /** 通过GCD 将数组存入本地. */
            /** 现将图片遍历存储到数组当中. */
            
            // 现创建一个并行的线程.
            dispatch_queue_t myQueue = dispatch_queue_create("loadImage", DISPATCH_QUEUE_CONCURRENT);
            // 创建主线程
            dispatch_queue_t mainQueue = dispatch_get_main_queue();
            dispatch_async(myQueue, ^{
                if (self.projectArray!= nil) {
                    for (WFProjectModel *model in self.projectArray) {
                        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[WFHandleURL getPicURL:model.coverPhoto]]];
                        UIImage *image = [UIImage imageWithData:data];
                        [self.imageArray addObject:image];
                    }
                    
                    /** userImageArray. */
                    //                [self.photoImageArray removeAllObjects];
                    
                    for (WFUserimageModel *imageModel in self.userImageArray) {
                        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageModel.small]];
                        UIImage *image = [UIImage imageWithData:data];
                        [self .photoImageArray addObject:image];
                    }
                    

                }
                                // 回到主队列
                dispatch_async(mainQueue, ^{
                    
                    /** 将imageArray存入本地. */
//                    NSLog(@"imageARraty: %@", self.imageArray);
                    [[StoreSandBox shareStoreSandBox] storeByArchiver:self.imageArray key:@"imageArray.plist"];
//                    NSLog(@"imageArray: %@", [[StoreSandBox shareStoreSandBox] readByArchiver:@"imageArray.plist"]);
                    [[StoreSandBox shareStoreSandBox] storeByArchiver:self.photoImageArray key:@"photoImageArray.plist"];
//                    NSLog(@"photoImageArray: %@", [[StoreSandBox shareStoreSandBox] readByArchiver:@"photoImageArray.plist"]);
                });

            });
            
            
            
            /** 在进界面的刷新和下拉的刷新时候讲判断是否拍缓存的标志和缓存时间存入NSUserDefaults中.*/
            [self saveLoadTimeAndSignal];
            


        } else {
            [self.projectArray addObjectsFromArray:array];
            [self createUserAndImageArray];

        }
        
        
        
        /** 刷新数据. */
        [_caseTableView reloadData];
#pragma mark - 创建tableView
        
        
//        /** 创建FreeDesign按钮. */
//        [self createFreeDesignButton];

        [self removeFailView];

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"请求失败.");
        /** 请求失败添加另一个页面. */
        [self createFailView];


        NSLog(@"%@", error);
    }];

}


- (void)createUserAndImageArray {
    NSMutableArray *arr = [NSMutableArray array];
    
    for (WFProjectModel *temp in self.projectArray) {
        [arr addObject:temp.user];
        
    }
    [self.userArray removeAllObjects];
    self.userArray = [WFUserModel baseModelByArray:arr];
    
    
    [self.userImageArray removeAllObjects];
    for (WFUserModel *temp in self.userArray) {
        WFUserimageModel *imageModel = [[WFUserimageModel alloc] init];
        [imageModel setValuesForKeysWithDictionary:(NSDictionary *)temp.userImage];
        [self.userImageArray addObject:imageModel];
        [imageModel release];
    }

}



/** 懒加载. */
- (void)createFailView {
    [self failView];
}


-(WFFailView *)failView {
    if (!_failView) {
        _failView = [[WFFailView alloc] initWithFrame:CGRectMake(0, 84, SCREEN_WIDTH, SCREEN_HEIGHT - 84 - 48)];
        [self.view addSubview:_failView];
        [_failView release];
        _failView.backgroundColor = [UIColor grayColor];
        _failView.delegate = self;
        
 
    }
    return _failView;
}
- (void)removeFailView{
    if (_failView) {
        [_failView removeFromSuperview];
        NSLog(@"failView移除成功. ");
    }
}
#pragma mark - 失败后的协议

- (void)reloadAgain {
    NSString *URL = [WFHandleURL caseHanleURLWithStyle:0 type:0 area:0 cost:0 user:@"(null)" start:self.start count:self.count];

    [self makeRequestWithUrl:URL upDown:YES];
}




/** 创建标题的. */
- (void)createTitleView {
    _titleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 34)];
    self.navigationItem.titleView = _titleImageView;
    [_titleImageView release];

    
    _titleImageView.image = [UIImage imageNamed:@"logo.png"];
}

/** 创建searchButton方法. */
- (void)createSearchButton {
    _searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _searchButton.frame = CGRectMake(0, 0, 32, 32);
    [_searchButton setBackgroundImage:[UIImage imageNamed:@"搜索.png"] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_searchButton];
    [_searchButton addTarget:self action:@selector(clickSearchButton:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}
- (void)clickSearchButton:(UIButton *)button {
    
    WFSearchViewController *searchVC = [[WFSearchViewController alloc] init];
    [self.navigationController pushViewController:searchVC animated:YES];
    [searchVC release];
//    NSLog(@"暂时将push的方法有此按钮实现. ");
    
}




#pragma mark - 找到下划线
- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
        return (UIImageView *)view;
    }
    for (UIView *subView in view.subviews) {
        UIImageView *imageView = [self findHairlineImageViewUnder:subView];
        if (imageView) {
            return imageView;
        }
    }
    return nil;
}





#pragma mark - 页面
- (void)createTableView {

    _caseTableView = [[WFCaseTableView alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 84 - 48) style:UITableViewStylePlain];
    [self.view addSubview:_caseTableView];
    [_caseTableView release];
    _caseTableView.delegate = self;
    _caseTableView.dataSource = self;
    _caseTableView.rowHeight = 240;
    
    [_caseTableView registerClass:[WFCaseCell class] forCellReuseIdentifier:@"pool"];
    
   
    
#pragma mark - 上拉/ 下拉刷新.
    _caseTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refresh)];
    _caseTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
    

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.projectArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    WFCaseCell *cell=[tableView dequeueReusableCellWithIdentifier:@"pool" forIndexPath:indexPath];
    cell.projectModel = _projectArray[indexPath.row];
    cell.userImageModel = _userImageArray[indexPath.row];
    NSLog(@"%d", self.cellImageStyle);
    if (self.imageArray.count != 0 && !self.cellImageStyle) {
        cell.mainImage = self.imageArray[indexPath.row];
        
    }
    if (self.photoImageArray.count != 0 && !self.cellImageStyle) {
        cell.photoImage = self.photoImageArray[indexPath.row];

    }
    cell.styleCell = self.cellImageStyle;
    cell.delegate = self;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    WFInformationVC *vc = [[WFInformationVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    WFProjectModel *model = self.projectArray[indexPath.row];

    WFUserModel *userModel = self.userArray[indexPath.row];
    NSString *urlStr = [WFHandleURL getClickUrl:userModel.userId id:model.id];
    vc.URL = urlStr;
    [vc release];
}
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
//    NSLog(@"偏移量: %f", _caseTableView.contentOffset.y);
//}
#pragma mark - 刷新的方法
- (void)refresh {
    self.cellImageStyle = 1;
    

    NSLog(@"下拉刷新开始.");
    self.start = 0;
    self.count = 10;
    NSString *URL = [WFHandleURL caseHanleURLWithStyle:self.style type:self.type area:self.area cost:self.cost user:@"(null)" start:self.start count:self.count];
    NSLog(@"%@", URL);
    [self makeRequestWithUrl:URL upDown:YES];
    
    [_caseTableView.mj_header endRefreshing];
    

    
    
    
}
- (void)loadMore {
    NSLog(@"上拉刷新开始");
    self.cellImageStyle = 1;
    self.start += 10;
//    self.count = self.count + 10;
    NSString *URL = [WFHandleURL caseHanleURLWithStyle:self.style type:self.type area:self.area cost:self.cost user:@"(null)" start:self.start count:self.count];
    [self makeRequestWithUrl:URL upDown:NO];
    [_caseTableView.mj_footer endRefreshing];
}

#pragma mark - caseCell的协议
- (void)tableViewReloadData {
    [_caseTableView reloadData];
}


#pragma mark - 懒加载
- (NSMutableArray *)projectArray {
    if (_projectArray == nil) {
        _projectArray = [[NSMutableArray array]retain];
    }
    return _projectArray;
}

- (NSInteger)start {
    if (!_start) {
        _start = 0;
    }
    return _start;
}

- (NSInteger)count {
    if (!_count) {
        _count = 10;
    }
    return _count;
}
- (NSMutableArray *)userArray {
    if (_userArray == nil) {
        _userArray = [[NSMutableArray array]retain];;
    }
    return _userArray;
}
- (NSMutableArray *)userImageArray {
    if (_userImageArray == nil) {
        _userImageArray = [[NSMutableArray array] retain];
    }
    return _userImageArray;
}

- (NSMutableArray *)carouselArray {
    if (_carouselArray == nil) {
        _carouselArray = [[NSMutableArray array] retain];
        
    }
    return _carouselArray;
}

- (BOOL)isNeedToRequest {
    if (!_isNeedToRequest) {
        _isNeedToRequest = 0;
    }
    return _isNeedToRequest;
}

- (NSMutableArray *)photoImageArray {
    if (_photoImageArray == nil) {
        _photoImageArray = [[NSMutableArray array] retain];
    }
    return _photoImageArray;
}


- (NSMutableArray *)imageArray {
    if (_imageArray == nil) {
        _imageArray = [[NSMutableArray array] retain];
    }
    return _imageArray;
}

- (NSMutableArray *)carouseCachesArray {
    if (_carouseCachesArray == nil) {
        _carouseCachesArray = [[NSMutableArray array] retain];
    }
    return _carouseCachesArray;
}
#pragma mark - 创建轮播图

- (void)createCarouselView {
    
    _carouselView = [[YJPCycleView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200) DataSource:self.carouselArray TimeInterval:1 cachesData:self.carouseCachesArray];
    [_caseTableView.tableHeaderView bringSubviewToFront:_carouselView];
    self.caseTableView.tableHeaderView = _carouselView;
    _carouselView.delegate = self;
    
//    [_caseTableView registerClass:[WFCaseCell class] forCellReuseIdentifier: @"pool"];
    
    

}


- (void)createCarouselVieData {
    /** 轮播图的网络请求. */
    NSString *str = @"http://api.guju.com.cn/v2/project/banner?src=appBannerOfProject";
    
    [NetWorkingTool netWorkingWithURL:str block:^(id result) {
        NSArray *carouselArr = [result valueForKey:@"banners"];
        /** 将轮播图的图片放在本地当中. */
        
        self.carouselArray = [WFCarouselModel baseModelByArray:carouselArr];
        [self createCarouselView];
        

    }];
}

#pragma mark - 点击轮播图的方法
- (void)didClickedItemAtIndexPath:(NSIndexPath *)indexPath {
    WFCarouselModel *carouseModel = self.carouselArray[indexPath.item];
    NSLog(@"type: %@", carouseModel.httpType);
    
    
    if ([carouseModel.httpType isEqualToString:@"project"]) {
        NSString *url = [NSString stringWithFormat:@"http://api.guju.com.cn/v2/project/%@/v2?userId=0", carouseModel.httpUrl];
        WFInformationVC *vc = [[WFInformationVC alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
        [vc release];
        vc.URL = url;
    } else {
        
    }
}


#pragma mark - 在第一次刷新数据和下拉刷新数据的时候讲刷新时间和判断是否有缓存的标志存入NSUserDefault中
- (void)saveLoadTimeAndSignal {
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isSave"];
    
    /** 获取当前时间. */
    NSString *locationString = [self getLastTime];
    /** 将刷新的最新一次时间存到本地. */
//    NSString *lastTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"time"];
    [[NSUserDefaults standardUserDefaults] setObject:locationString forKey:@"time"];
    
}


#pragma mark - 在进入界面之前读缓存
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [_caseTableView reloadData];
    _navBarHairlineImageView.hidden = YES;
#warning mark - is not sure 
    
    /** 先判断*/
    
    
//    self.isHadData =
//    /** 在进入加载界面之前先进行本地请求. */
//    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isSave"]) {
//        [self makeRequestWithCaches];
//        
//        /** 判断数据是否过期*/
//        
//        /** 获取当前时间. */
//        NSString *locationTime = [self getLastTime];
//        /** 将当前时间转换为NSInteger类型. */
//        NSInteger locationInt = [locationTime integerValue];
//        
//        /** 获取本地当中存储的赏赐刷新时间. */
//        NSString *lastTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"time"];
//        NSInteger lastInt = [lastTime integerValue];
//        
//        if (labs(lastInt - locationInt) >= 5) {
//            /** 过时间间隔超过了五个小时, 刷新. */
//#pragma mark - 网络请求
//            NSString *URL = [WFHandleURL caseHanleURLWithStyle:0 type:0 area:0 cost:0 user:@"(null)" start:0 count:self.count];
//            
//            [self makeRequestWithUrl:URL upDown:YES];
//            
//            
//        }
//
//    } else {
//        NSString *URL = [WFHandleURL caseHanleURLWithStyle:0 type:0 area:0 cost:0 user:@"(null)" start:0 count:self.count];
//        
//        [self makeRequestWithUrl:URL upDown:YES];
//        
//
//    }

    
    
}

#pragma mark - 获取当前时间的方法
- (NSString *)getLastTime {
    NSDate *date = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"HH"];
    NSString *locationString = [dateFormatter stringFromDate:date];
    return locationString;
}

- (void)viewDidAppear:(BOOL)animated {
    NSLog(@"案例出现. ");
    SYMBOL = @0;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"symbolChange" object:nil];

}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    _navBarHairlineImageView.hidden = NO;
}
- (void)dealloc {
    [_titleDic release];
    [super dealloc];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
